<template>
  <!--级联选择组件-->
  <div class="cascader" v-show="$store.state.app.c.show2">
    <div class="container1">
    </div>
    <!--容器-->
    <div class="container2">
      <!--头部-->
      <div class="header">
        <div class="h-n">
          <div class="font1" @click="tag">
            取消
          </div>
          <div class="font2" @click="sure">
            确定
          </div>
        </div>
      </div>
      <!--内容-->
      <div class="content">
        <mt-picker :slots="slots" value-key="str" @change="onChange"></mt-picker>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "supervisor",
    data() {
      return {
        name:"",
        slots:[
          {
            flex: 1,
            values:this.$store.state.app.cp.legals,
            className: 'slot1',
            textAlign: 'center'
          }
        ],
      };
    },
    methods: {

      onChange(picker, values){
        if (values[0]){
          this.name=values[0].name;
        }
      },
      sure(){
        let l=this.$store.state.app.cp.legals;
        l.forEach(i=>{
          //找到type=1的
          if (i.type==1){
            i.type=0;
          }
          if (i.name==this.name){
             i.type=1;
          }
        });
        this.$store.commit("cpLegals",l);
        this.$store.commit("cShow2",false);
      },
      tag(){
        this.$store.commit("cShow2",false);
      },


    },


  }
</script>

<style lang="less" scoped>
  @import "./less/my-cascader";
</style>
